<template>
  <div class="box">
    <el-row>
      <el-col :span="24">
        <el-card shadow="never">
          <el-page-header @back="goBack" :content="`【${jsonData.title}】详情页面`"></el-page-header>
          <el-alert
            title="三级路由【缓存路由、固定表格高度、并根据窗口大小自适应】的示例。详情页请点击操作列按钮，支持tab多开并高亮左侧菜单"
            type="success"
            :closable="false"
            show-icon
          ></el-alert>
          <el-col :span="24">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
              <el-form-item label="输入框缓存">
                <el-input v-model="formInline.region"></el-input>
              </el-form-item>
              <el-form-item>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSubmit"><i class="el-icon-refresh"></i>刷新综合表格页面</el-button>
              </el-form-item>
            </el-form>
          </el-col>
          <el-col :span="24" class="description-detail">
            <el-descriptions class="margin-top" title="详情" :column="3" size="medium" border>
              <template slot="extra">
                <el-button type="primary" size="small">操作</el-button>
              </template>
              <el-descriptions-item>
                <template slot="label">标题</template>
                {{jsonData.title}}
              </el-descriptions-item>
              <el-descriptions-item>

                <template slot="label">
                  作者
                </template>
                {{jsonData.name}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  时间
                </template>
                {{jsonData.date}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  评级
                </template>
                <el-rate
                  :max="3"
                  :value="jsonData.rate"
                  :colors="colors"
                >
                </el-rate>
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  备注
                </template>
                {{jsonData.paragraph}}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  联系地址
                </template>
                {{jsonData.address+jsonData.house+'号'}}
              </el-descriptions-item>
            </el-descriptions>
          </el-col>


          <el-col :span="24">
              <json-viewer
                :value="jsonData"
                :expand-depth="5"
                boxed
                copyable
                sort
              >
              </json-viewer>


          </el-col>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>

export default {
  name: 'index',
  data() {
    return {
      visible: false,
      jsonData: {},
      jsonStr: '',
      jsonData1:{},
      colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
      formInline: {
        region: ''
      }
    }
  },
  methods: {
    copyCode(){
    },
    goBack() {
      this.$router.go(-1)
    },
    onSubmit() {
      console.log('submit!')
    },
    getData() {
      let list = this.$store.state.user.jsonData || []
      for (let i = 0; i < list.length; i++) {
        if (list[i].id.indexOf(this.$route.query.id) >= 0) {
          this.jsonData = list[i]
          this.jsonStr = JSON.stringify(list[i],null,2)
          break
        }
      }
    }
  },
  mounted() {
    this.getData()
  }
}
</script>

<style scoped lang="scss">
.box {
  ::v-deep.el-alert__icon {
    margin-top: 3px;
  }

  ::v-deep.el-descriptions-item__label {
    font-weight: 700;
    color: #606266;
  }

  ::v-deep.el-descriptions-item__content {
    color: #303133;
    text-align: left;
    font-weight: 400;
    line-height: 23px;
    font-size: 14px;
  }

  ::v-deep.el-form-item__label {
    font-weight: 400;
  }

  .el-icon-refresh {
    margin-right: 5px;
  }

  .el-form--inline {
    margin-top: 20px;
  }

  .el-page-header {
    margin-bottom: 20px;
  }

  .description-detail {
    ::v-deep.el-descriptions__title {
      padding-left: 10px;
      border-left: 5px solid #1890ff;
    }
  }

  .jv-container {
    margin-top: 20px;
    border: none;
    border-radius: 0;
    min-height: 350px;
    pointer-events:none;
    .jv-code{
      cursor: text;
    }
  }
}
</style>
